package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.system.domain.TreeHoleReadRecords;
import com.hello.system.service.ITreeHoleReadRecordsService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 树洞内容已阅记录Controller
 * 
 * @author hello
 * @date 2025-05-27
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/records")
public class TreeHoleReadRecordsController extends BaseController
{
    private final ITreeHoleReadRecordsService treeHoleReadRecordsService;

    /**
     * 查询树洞内容已阅记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TreeHoleReadRecords treeHoleReadRecords)
    {
        startPage();
        List<TreeHoleReadRecords> list = treeHoleReadRecordsService.selectTreeHoleReadRecordsList(treeHoleReadRecords);
        return getDataTable(list);
    }

    /**
     * 导出树洞内容已阅记录列表
     */
    @Log(title = "树洞内容已阅记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TreeHoleReadRecords treeHoleReadRecords)
    {
        List<TreeHoleReadRecords> list = treeHoleReadRecordsService.selectTreeHoleReadRecordsList(treeHoleReadRecords);
        ExcelUtil<TreeHoleReadRecords> util = new ExcelUtil<TreeHoleReadRecords>(TreeHoleReadRecords.class);
        util.exportExcel(response, list, "树洞内容已阅记录数据");
    }

    /**
     * 获取树洞内容已阅记录详细信息
     */
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(treeHoleReadRecordsService.selectTreeHoleReadRecordsByRecordId(recordId));
    }

    /**
     * 新增树洞内容已阅记录
     */
    @Log(title = "树洞内容已阅记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TreeHoleReadRecords treeHoleReadRecords)
    {
        return toAjax(treeHoleReadRecordsService.insertTreeHoleReadRecords(treeHoleReadRecords));
    }

    /**
     * 修改树洞内容已阅记录
     */
    @Log(title = "树洞内容已阅记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TreeHoleReadRecords treeHoleReadRecords)
    {
        return toAjax(treeHoleReadRecordsService.updateTreeHoleReadRecords(treeHoleReadRecords));
    }

    /**
     * 删除树洞内容已阅记录
     */
    @Log(title = "树洞内容已阅记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(treeHoleReadRecordsService.deleteTreeHoleReadRecordsByRecordIds(recordIds));
    }
}
